package com.wsd.jing.exception;

import com.wsd.jing.enums.CodeEnum;
import lombok.Data;

/**
 * All rights Reserved, Designed By www.tom.com
 *
 * @author tom
 * @version 1.0.0
 * @projectName: jing
 * @packageName: com.wsd.jing.exception
 * @className: BusinessException
 * @description 自定义业务异常类
 * @createDate 2022/11/14 17:14
 * @copyright 2022/11/14 17:14 www.tom.com Inc. All rights reserved.
 */
@Data
public class BusinessException extends RuntimeException {

    /**
     * 错误码
     */
    private Integer code;

    /**
     * 错误信息
     */
    private String message;

    public BusinessException(Integer code, String message) {
        super(message);
        this.code = code;
        this.message = message;
    }

    public BusinessException(CodeEnum codeEnum) {
        super(codeEnum.getMessage());
        this.code = codeEnum.getCode();
        this.message = codeEnum.getMessage();
    }
}
